#!/usr/bin/python3

from threading import Thread
import time

class myThread(Thread):
    def __init__(self, name, delay, n = 10):
        print (f"thread {name} __init__() start")
        super().__init__()
        self.name = name
        self.delay = delay
        self.n = n
        print (f"thread {name} __init__() end")

    def run(self):
        print (f"thread {self.name} run() start")

        for i in range(1,self.n+1):
            print(f"thread {self.name} count {i}/{self.n}")
            time.sleep(self.delay)

        print (f"thread {self.name} run() end")



# 创建新线程
print("创建线程 start")
thread1 = myThread("Thread-1", 1, 10)
thread2 = myThread("Thread-2", 2, 10)
print("创建线程 end")

# 开启新线程
print("开启线程 start")
thread1.start()
thread2.start()
print("开启线程 end")

# print ("thread1 join")
# thread1.join()
# print ("thread1 joined")

# print ("thread2 join")
# thread2.join()
# print ("thread2 joined")

print ("退出主线程")